{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:23.084428200Z",
     "start_time": "2023-12-13T02:21:20.271212Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "data": {
      "text/plain": "   Status  Seniority  Home  Time  Age  Marital  Records  Job  Expenses  \\\n0       1          9     1    60   30        2        1    3        73   \n1       1         17     1    60   58        3        1    1        48   \n2       2         10     2    36   46        2        2    3        90   \n3       1          0     1    60   24        1        1    1        63   \n4       1          0     1    36   26        1        1    1        46   \n\n   Income  Assets  Debt  Amount  Price  \n0     129       0     0     800    846  \n1     131       0     0    1000   1658  \n2     200    3000     0    2000   2985  \n3     182    2500     0     900   1325  \n4     107       0     0     310    910  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Status</th>\n      <th>Seniority</th>\n      <th>Home</th>\n      <th>Time</th>\n      <th>Age</th>\n      <th>Marital</th>\n      <th>Records</th>\n      <th>Job</th>\n      <th>Expenses</th>\n      <th>Income</th>\n      <th>Assets</th>\n      <th>Debt</th>\n      <th>Amount</th>\n      <th>Price</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1</td>\n      <td>9</td>\n      <td>1</td>\n      <td>60</td>\n      <td>30</td>\n      <td>2</td>\n      <td>1</td>\n      <td>3</td>\n      <td>73</td>\n      <td>129</td>\n      <td>0</td>\n      <td>0</td>\n      <td>800</td>\n      <td>846</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>1</td>\n      <td>17</td>\n      <td>1</td>\n      <td>60</td>\n      <td>58</td>\n      <td>3</td>\n      <td>1</td>\n      <td>1</td>\n      <td>48</td>\n      <td>131</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1000</td>\n      <td>1658</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2</td>\n      <td>10</td>\n      <td>2</td>\n      <td>36</td>\n      <td>46</td>\n      <td>2</td>\n      <td>2</td>\n      <td>3</td>\n      <td>90</td>\n      <td>200</td>\n      <td>3000</td>\n      <td>0</td>\n      <td>2000</td>\n      <td>2985</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>60</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>63</td>\n      <td>182</td>\n      <td>2500</td>\n      <td>0</td>\n      <td>900</td>\n      <td>1325</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>36</td>\n      <td>26</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>46</td>\n      <td>107</td>\n      <td>0</td>\n      <td>0</td>\n      <td>310</td>\n      <td>910</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('CreditScoring.csv')\n",
    "df.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:23.447798500Z",
     "start_time": "2023-12-13T02:21:23.156405300Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 数据清理"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "data": {
      "text/plain": "   status  seniority  home  time  age  marital  records  job  expenses  \\\n0       1          9     1    60   30        2        1    3        73   \n1       1         17     1    60   58        3        1    1        48   \n2       2         10     2    36   46        2        2    3        90   \n3       1          0     1    60   24        1        1    1        63   \n4       1          0     1    36   26        1        1    1        46   \n\n   income  assets  debt  amount  price  \n0     129       0     0     800    846  \n1     131       0     0    1000   1658  \n2     200    3000     0    2000   2985  \n3     182    2500     0     900   1325  \n4     107       0     0     310    910  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>status</th>\n      <th>seniority</th>\n      <th>home</th>\n      <th>time</th>\n      <th>age</th>\n      <th>marital</th>\n      <th>records</th>\n      <th>job</th>\n      <th>expenses</th>\n      <th>income</th>\n      <th>assets</th>\n      <th>debt</th>\n      <th>amount</th>\n      <th>price</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1</td>\n      <td>9</td>\n      <td>1</td>\n      <td>60</td>\n      <td>30</td>\n      <td>2</td>\n      <td>1</td>\n      <td>3</td>\n      <td>73</td>\n      <td>129</td>\n      <td>0</td>\n      <td>0</td>\n      <td>800</td>\n      <td>846</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>1</td>\n      <td>17</td>\n      <td>1</td>\n      <td>60</td>\n      <td>58</td>\n      <td>3</td>\n      <td>1</td>\n      <td>1</td>\n      <td>48</td>\n      <td>131</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1000</td>\n      <td>1658</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2</td>\n      <td>10</td>\n      <td>2</td>\n      <td>36</td>\n      <td>46</td>\n      <td>2</td>\n      <td>2</td>\n      <td>3</td>\n      <td>90</td>\n      <td>200</td>\n      <td>3000</td>\n      <td>0</td>\n      <td>2000</td>\n      <td>2985</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>60</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>63</td>\n      <td>182</td>\n      <td>2500</td>\n      <td>0</td>\n      <td>900</td>\n      <td>1325</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>36</td>\n      <td>26</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>46</td>\n      <td>107</td>\n      <td>0</td>\n      <td>0</td>\n      <td>310</td>\n      <td>910</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns = df.columns.str.lower() # 先将列名转为小写\n",
    "df.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:23.462765400Z",
     "start_time": "2023-12-13T02:21:23.453776400Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "data": {
      "text/plain": "    status  seniority  home  time  age  marital  records  job  expenses  \\\n0       ok          9     1    60   30        2        1    3        73   \n1       ok         17     1    60   58        3        1    1        48   \n2  default         10     2    36   46        2        2    3        90   \n3       ok          0     1    60   24        1        1    1        63   \n4       ok          0     1    36   26        1        1    1        46   \n\n   income  assets  debt  amount  price  \n0     129       0     0     800    846  \n1     131       0     0    1000   1658  \n2     200    3000     0    2000   2985  \n3     182    2500     0     900   1325  \n4     107       0     0     310    910  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>status</th>\n      <th>seniority</th>\n      <th>home</th>\n      <th>time</th>\n      <th>age</th>\n      <th>marital</th>\n      <th>records</th>\n      <th>job</th>\n      <th>expenses</th>\n      <th>income</th>\n      <th>assets</th>\n      <th>debt</th>\n      <th>amount</th>\n      <th>price</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>ok</td>\n      <td>9</td>\n      <td>1</td>\n      <td>60</td>\n      <td>30</td>\n      <td>2</td>\n      <td>1</td>\n      <td>3</td>\n      <td>73</td>\n      <td>129</td>\n      <td>0</td>\n      <td>0</td>\n      <td>800</td>\n      <td>846</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>ok</td>\n      <td>17</td>\n      <td>1</td>\n      <td>60</td>\n      <td>58</td>\n      <td>3</td>\n      <td>1</td>\n      <td>1</td>\n      <td>48</td>\n      <td>131</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1000</td>\n      <td>1658</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>default</td>\n      <td>10</td>\n      <td>2</td>\n      <td>36</td>\n      <td>46</td>\n      <td>2</td>\n      <td>2</td>\n      <td>3</td>\n      <td>90</td>\n      <td>200</td>\n      <td>3000</td>\n      <td>0</td>\n      <td>2000</td>\n      <td>2985</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>ok</td>\n      <td>0</td>\n      <td>1</td>\n      <td>60</td>\n      <td>24</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>63</td>\n      <td>182</td>\n      <td>2500</td>\n      <td>0</td>\n      <td>900</td>\n      <td>1325</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>ok</td>\n      <td>0</td>\n      <td>1</td>\n      <td>36</td>\n      <td>26</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>46</td>\n      <td>107</td>\n      <td>0</td>\n      <td>0</td>\n      <td>310</td>\n      <td>910</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将数值型变量转化为字符型变量\n",
    "status_values = {\n",
    "    1:'ok',\n",
    "    2:'default',\n",
    "    0:'unk'\n",
    "}\n",
    "df.status = df.status.map(status_values)\n",
    "df.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:23.676763400Z",
     "start_time": "2023-12-13T02:21:23.464781400Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "data": {
      "text/plain": "    status  seniority   home  time  age  marital records        job  expenses  \\\n0       ok          9   rent    60   30  married      no  freelance        73   \n1       ok         17   rent    60   58    widow      no      fixed        48   \n2  default         10  owner    36   46  married     yes  freelance        90   \n3       ok          0   rent    60   24   single      no      fixed        63   \n4       ok          0   rent    36   26   single      no      fixed        46   \n\n   income  assets  debt  amount  price  \n0     129       0     0     800    846  \n1     131       0     0    1000   1658  \n2     200    3000     0    2000   2985  \n3     182    2500     0     900   1325  \n4     107       0     0     310    910  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>status</th>\n      <th>seniority</th>\n      <th>home</th>\n      <th>time</th>\n      <th>age</th>\n      <th>marital</th>\n      <th>records</th>\n      <th>job</th>\n      <th>expenses</th>\n      <th>income</th>\n      <th>assets</th>\n      <th>debt</th>\n      <th>amount</th>\n      <th>price</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>ok</td>\n      <td>9</td>\n      <td>rent</td>\n      <td>60</td>\n      <td>30</td>\n      <td>married</td>\n      <td>no</td>\n      <td>freelance</td>\n      <td>73</td>\n      <td>129</td>\n      <td>0</td>\n      <td>0</td>\n      <td>800</td>\n      <td>846</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>ok</td>\n      <td>17</td>\n      <td>rent</td>\n      <td>60</td>\n      <td>58</td>\n      <td>widow</td>\n      <td>no</td>\n      <td>fixed</td>\n      <td>48</td>\n      <td>131</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1000</td>\n      <td>1658</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>default</td>\n      <td>10</td>\n      <td>owner</td>\n      <td>36</td>\n      <td>46</td>\n      <td>married</td>\n      <td>yes</td>\n      <td>freelance</td>\n      <td>90</td>\n      <td>200</td>\n      <td>3000</td>\n      <td>0</td>\n      <td>2000</td>\n      <td>2985</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>ok</td>\n      <td>0</td>\n      <td>rent</td>\n      <td>60</td>\n      <td>24</td>\n      <td>single</td>\n      <td>no</td>\n      <td>fixed</td>\n      <td>63</td>\n      <td>182</td>\n      <td>2500</td>\n      <td>0</td>\n      <td>900</td>\n      <td>1325</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>ok</td>\n      <td>0</td>\n      <td>rent</td>\n      <td>36</td>\n      <td>26</td>\n      <td>single</td>\n      <td>no</td>\n      <td>fixed</td>\n      <td>46</td>\n      <td>107</td>\n      <td>0</td>\n      <td>0</td>\n      <td>310</td>\n      <td>910</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "home_values = {\n",
    "    1:'rent',\n",
    "    2:'owner',\n",
    "    3:'private',\n",
    "    4:'ignore',\n",
    "    5:'parents',\n",
    "    6:'other',\n",
    "    0:'unk'\n",
    "}\n",
    "df.home = df.home.map(home_values)\n",
    "\n",
    "marital_values = {\n",
    "    1:'single',\n",
    "    2:'married',\n",
    "    3:'widow',\n",
    "    4:'separated',\n",
    "    5:'divorced',\n",
    "    0:'unk'\n",
    "}\n",
    "df.marital = df.marital.map(marital_values)\n",
    "\n",
    "records_values = {\n",
    "    1:'no',\n",
    "    2:'yes',\n",
    "    0:'unk'\n",
    "}\n",
    "df.records = df.records.map(records_values)\n",
    "\n",
    "job_values = {\n",
    "    1:'fixed',\n",
    "    2:'parttime',\n",
    "    3:'freelance',\n",
    "    4:'others',\n",
    "    0:'unk'\n",
    "}\n",
    "df.job = df.job.map(job_values)\n",
    "\n",
    "df.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:25.043260600Z",
     "start_time": "2023-12-13T02:21:23.526762600Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "data": {
      "text/plain": "       seniority    time     age  expenses      income      assets  \\\ncount     4455.0  4455.0  4455.0    4455.0      4455.0      4455.0   \nmean         8.0    46.0    37.0      56.0    763317.0   1060341.0   \nstd          8.0    15.0    11.0      20.0   8703625.0  10217569.0   \nmin          0.0     6.0    18.0      35.0         0.0         0.0   \n25%          2.0    36.0    28.0      35.0        80.0         0.0   \n50%          5.0    48.0    36.0      51.0       120.0      3500.0   \n75%         12.0    60.0    45.0      72.0       166.0      6000.0   \nmax         48.0    72.0    68.0     180.0  99999999.0  99999999.0   \n\n             debt  amount    price  \ncount      4455.0  4455.0   4455.0  \nmean     404382.0  1039.0   1463.0  \nstd     6344253.0   475.0    628.0  \nmin           0.0   100.0    105.0  \n25%           0.0   700.0   1118.0  \n50%           0.0  1000.0   1400.0  \n75%           0.0  1300.0   1692.0  \nmax    99999999.0  5000.0  11140.0  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>seniority</th>\n      <th>time</th>\n      <th>age</th>\n      <th>expenses</th>\n      <th>income</th>\n      <th>assets</th>\n      <th>debt</th>\n      <th>amount</th>\n      <th>price</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>count</th>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n    </tr>\n    <tr>\n      <th>mean</th>\n      <td>8.0</td>\n      <td>46.0</td>\n      <td>37.0</td>\n      <td>56.0</td>\n      <td>763317.0</td>\n      <td>1060341.0</td>\n      <td>404382.0</td>\n      <td>1039.0</td>\n      <td>1463.0</td>\n    </tr>\n    <tr>\n      <th>std</th>\n      <td>8.0</td>\n      <td>15.0</td>\n      <td>11.0</td>\n      <td>20.0</td>\n      <td>8703625.0</td>\n      <td>10217569.0</td>\n      <td>6344253.0</td>\n      <td>475.0</td>\n      <td>628.0</td>\n    </tr>\n    <tr>\n      <th>min</th>\n      <td>0.0</td>\n      <td>6.0</td>\n      <td>18.0</td>\n      <td>35.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>100.0</td>\n      <td>105.0</td>\n    </tr>\n    <tr>\n      <th>25%</th>\n      <td>2.0</td>\n      <td>36.0</td>\n      <td>28.0</td>\n      <td>35.0</td>\n      <td>80.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>700.0</td>\n      <td>1118.0</td>\n    </tr>\n    <tr>\n      <th>50%</th>\n      <td>5.0</td>\n      <td>48.0</td>\n      <td>36.0</td>\n      <td>51.0</td>\n      <td>120.0</td>\n      <td>3500.0</td>\n      <td>0.0</td>\n      <td>1000.0</td>\n      <td>1400.0</td>\n    </tr>\n    <tr>\n      <th>75%</th>\n      <td>12.0</td>\n      <td>60.0</td>\n      <td>45.0</td>\n      <td>72.0</td>\n      <td>166.0</td>\n      <td>6000.0</td>\n      <td>0.0</td>\n      <td>1300.0</td>\n      <td>1692.0</td>\n    </tr>\n    <tr>\n      <th>max</th>\n      <td>48.0</td>\n      <td>72.0</td>\n      <td>68.0</td>\n      <td>180.0</td>\n      <td>99999999.0</td>\n      <td>99999999.0</td>\n      <td>99999999.0</td>\n      <td>5000.0</td>\n      <td>11140.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe().round()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:25.137260600Z",
     "start_time": "2023-12-13T02:21:23.555775800Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "data": {
      "text/plain": "       seniority    time     age  expenses  income    assets     debt  amount  \\\ncount     4455.0  4455.0  4455.0    4455.0  4421.0    4408.0   4437.0  4455.0   \nmean         8.0    46.0    37.0      56.0   131.0    5403.0    343.0  1039.0   \nstd          8.0    15.0    11.0      20.0    86.0   11573.0   1246.0   475.0   \nmin          0.0     6.0    18.0      35.0     0.0       0.0      0.0   100.0   \n25%          2.0    36.0    28.0      35.0    80.0       0.0      0.0   700.0   \n50%          5.0    48.0    36.0      51.0   120.0    3000.0      0.0  1000.0   \n75%         12.0    60.0    45.0      72.0   165.0    6000.0      0.0  1300.0   \nmax         48.0    72.0    68.0     180.0   959.0  300000.0  30000.0  5000.0   \n\n         price  \ncount   4455.0  \nmean    1463.0  \nstd      628.0  \nmin      105.0  \n25%     1118.0  \n50%     1400.0  \n75%     1692.0  \nmax    11140.0  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>seniority</th>\n      <th>time</th>\n      <th>age</th>\n      <th>expenses</th>\n      <th>income</th>\n      <th>assets</th>\n      <th>debt</th>\n      <th>amount</th>\n      <th>price</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>count</th>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n      <td>4421.0</td>\n      <td>4408.0</td>\n      <td>4437.0</td>\n      <td>4455.0</td>\n      <td>4455.0</td>\n    </tr>\n    <tr>\n      <th>mean</th>\n      <td>8.0</td>\n      <td>46.0</td>\n      <td>37.0</td>\n      <td>56.0</td>\n      <td>131.0</td>\n      <td>5403.0</td>\n      <td>343.0</td>\n      <td>1039.0</td>\n      <td>1463.0</td>\n    </tr>\n    <tr>\n      <th>std</th>\n      <td>8.0</td>\n      <td>15.0</td>\n      <td>11.0</td>\n      <td>20.0</td>\n      <td>86.0</td>\n      <td>11573.0</td>\n      <td>1246.0</td>\n      <td>475.0</td>\n      <td>628.0</td>\n    </tr>\n    <tr>\n      <th>min</th>\n      <td>0.0</td>\n      <td>6.0</td>\n      <td>18.0</td>\n      <td>35.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>100.0</td>\n      <td>105.0</td>\n    </tr>\n    <tr>\n      <th>25%</th>\n      <td>2.0</td>\n      <td>36.0</td>\n      <td>28.0</td>\n      <td>35.0</td>\n      <td>80.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>700.0</td>\n      <td>1118.0</td>\n    </tr>\n    <tr>\n      <th>50%</th>\n      <td>5.0</td>\n      <td>48.0</td>\n      <td>36.0</td>\n      <td>51.0</td>\n      <td>120.0</td>\n      <td>3000.0</td>\n      <td>0.0</td>\n      <td>1000.0</td>\n      <td>1400.0</td>\n    </tr>\n    <tr>\n      <th>75%</th>\n      <td>12.0</td>\n      <td>60.0</td>\n      <td>45.0</td>\n      <td>72.0</td>\n      <td>165.0</td>\n      <td>6000.0</td>\n      <td>0.0</td>\n      <td>1300.0</td>\n      <td>1692.0</td>\n    </tr>\n    <tr>\n      <th>max</th>\n      <td>48.0</td>\n      <td>72.0</td>\n      <td>68.0</td>\n      <td>180.0</td>\n      <td>959.0</td>\n      <td>300000.0</td>\n      <td>30000.0</td>\n      <td>5000.0</td>\n      <td>11140.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "for c in ['income','assets','debt']:\n",
    "    df[c] = df[c].replace(to_replace=99999999,value=np.nan) # 将非常大的值转化为nan\n",
    "df.describe().round()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:25.199261800Z",
     "start_time": "2023-12-13T02:21:25.038260800Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "data": {
      "text/plain": "ok         3200\ndefault    1254\nunk           1\nName: status, dtype: int64"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.status.value_counts()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:25.199261800Z",
     "start_time": "2023-12-13T02:21:25.040262Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [],
   "source": [
    "df = df[df.status!='unk']"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:25.200269200Z",
     "start_time": "2023-12-13T02:21:25.040262Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 准备数据集"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "outputs": [
    {
     "data": {
      "text/plain": "(2672, 891, 891)"
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "df_train_full,df_test = train_test_split(df,test_size=0.2,random_state=11)\n",
    "df_train,df_val = train_test_split(df_train_full,test_size=0.25,random_state=11)\n",
    "len(df_train),len(df_val),len(df_test)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:30.384371900Z",
     "start_time": "2023-12-13T02:21:25.040262Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "outputs": [],
   "source": [
    "df_train=df_train.fillna(0) # 填补空值\n",
    "df_val=df_val.fillna(0)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:30.457368900Z",
     "start_time": "2023-12-13T02:21:30.386398500Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "data": {
      "text/plain": "    status  seniority   home  time  age  marital records        job  expenses  \\\n0       ok          9   rent    60   30  married      no  freelance        73   \n1       ok         17   rent    60   58    widow      no      fixed        48   \n2  default         10  owner    36   46  married     yes  freelance        90   \n3       ok          0   rent    60   24   single      no      fixed        63   \n4       ok          0   rent    36   26   single      no      fixed        46   \n\n   income  assets  debt  amount  price  \n0   129.0     0.0   0.0     800    846  \n1   131.0     0.0   0.0    1000   1658  \n2   200.0  3000.0   0.0    2000   2985  \n3   182.0  2500.0   0.0     900   1325  \n4   107.0     0.0   0.0     310    910  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>status</th>\n      <th>seniority</th>\n      <th>home</th>\n      <th>time</th>\n      <th>age</th>\n      <th>marital</th>\n      <th>records</th>\n      <th>job</th>\n      <th>expenses</th>\n      <th>income</th>\n      <th>assets</th>\n      <th>debt</th>\n      <th>amount</th>\n      <th>price</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>ok</td>\n      <td>9</td>\n      <td>rent</td>\n      <td>60</td>\n      <td>30</td>\n      <td>married</td>\n      <td>no</td>\n      <td>freelance</td>\n      <td>73</td>\n      <td>129.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>800</td>\n      <td>846</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>ok</td>\n      <td>17</td>\n      <td>rent</td>\n      <td>60</td>\n      <td>58</td>\n      <td>widow</td>\n      <td>no</td>\n      <td>fixed</td>\n      <td>48</td>\n      <td>131.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1000</td>\n      <td>1658</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>default</td>\n      <td>10</td>\n      <td>owner</td>\n      <td>36</td>\n      <td>46</td>\n      <td>married</td>\n      <td>yes</td>\n      <td>freelance</td>\n      <td>90</td>\n      <td>200.0</td>\n      <td>3000.0</td>\n      <td>0.0</td>\n      <td>2000</td>\n      <td>2985</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>ok</td>\n      <td>0</td>\n      <td>rent</td>\n      <td>60</td>\n      <td>24</td>\n      <td>single</td>\n      <td>no</td>\n      <td>fixed</td>\n      <td>63</td>\n      <td>182.0</td>\n      <td>2500.0</td>\n      <td>0.0</td>\n      <td>900</td>\n      <td>1325</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>ok</td>\n      <td>0</td>\n      <td>rent</td>\n      <td>36</td>\n      <td>26</td>\n      <td>single</td>\n      <td>no</td>\n      <td>fixed</td>\n      <td>46</td>\n      <td>107.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>310</td>\n      <td>910</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_train = (df_train.status=='default').values\n",
    "y_val = (df_val.status=='default').values\n",
    "del df_train['status']\n",
    "del df_val['status']\n",
    "df.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:30.459369100Z",
     "start_time": "2023-12-13T02:21:30.426367Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [
    {
     "data": {
      "text/plain": "      seniority     home  time  age  marital records        job  expenses  \\\n951          10    owner    36   36  married      no  freelance        75   \n688           6  parents    48   32   single     yes      fixed        35   \n2233          1  parents    48   40  married      no      fixed        75   \n3304          1  parents    48   23   single      no   parttime        35   \n2271          5    owner    36   46  married      no  freelance        60   \n\n      income   assets  debt  amount  price  \n951      0.0  10000.0   0.0    1000   1400  \n688     85.0      0.0   0.0    1100   1330  \n2233   121.0      0.0   0.0    1320   1600  \n3304    72.0      0.0   0.0    1078   1079  \n2271   100.0   4000.0   0.0    1100   1897  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>seniority</th>\n      <th>home</th>\n      <th>time</th>\n      <th>age</th>\n      <th>marital</th>\n      <th>records</th>\n      <th>job</th>\n      <th>expenses</th>\n      <th>income</th>\n      <th>assets</th>\n      <th>debt</th>\n      <th>amount</th>\n      <th>price</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>951</th>\n      <td>10</td>\n      <td>owner</td>\n      <td>36</td>\n      <td>36</td>\n      <td>married</td>\n      <td>no</td>\n      <td>freelance</td>\n      <td>75</td>\n      <td>0.0</td>\n      <td>10000.0</td>\n      <td>0.0</td>\n      <td>1000</td>\n      <td>1400</td>\n    </tr>\n    <tr>\n      <th>688</th>\n      <td>6</td>\n      <td>parents</td>\n      <td>48</td>\n      <td>32</td>\n      <td>single</td>\n      <td>yes</td>\n      <td>fixed</td>\n      <td>35</td>\n      <td>85.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1100</td>\n      <td>1330</td>\n    </tr>\n    <tr>\n      <th>2233</th>\n      <td>1</td>\n      <td>parents</td>\n      <td>48</td>\n      <td>40</td>\n      <td>married</td>\n      <td>no</td>\n      <td>fixed</td>\n      <td>75</td>\n      <td>121.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1320</td>\n      <td>1600</td>\n    </tr>\n    <tr>\n      <th>3304</th>\n      <td>1</td>\n      <td>parents</td>\n      <td>48</td>\n      <td>23</td>\n      <td>single</td>\n      <td>no</td>\n      <td>parttime</td>\n      <td>35</td>\n      <td>72.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1078</td>\n      <td>1079</td>\n    </tr>\n    <tr>\n      <th>2271</th>\n      <td>5</td>\n      <td>owner</td>\n      <td>36</td>\n      <td>46</td>\n      <td>married</td>\n      <td>no</td>\n      <td>freelance</td>\n      <td>60</td>\n      <td>100.0</td>\n      <td>4000.0</td>\n      <td>0.0</td>\n      <td>1100</td>\n      <td>1897</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_train.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:30.494372Z",
     "start_time": "2023-12-13T02:21:30.452368700Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "outputs": [
    {
     "data": {
      "text/plain": "array([ True,  True, False,  True, False])"
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_train[:5]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:30.549370300Z",
     "start_time": "2023-12-13T02:21:30.484370900Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 使用独热编码"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "outputs": [
    {
     "data": {
      "text/plain": "{'seniority': 6,\n 'home': 'parents',\n 'time': 48,\n 'age': 32,\n 'marital': 'single',\n 'records': 'yes',\n 'job': 'fixed',\n 'expenses': 35,\n 'income': 85.0,\n 'assets': 0.0,\n 'debt': 0.0,\n 'amount': 1100,\n 'price': 1330}"
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_train = df_train.to_dict(orient='records')\n",
    "dict_val = df_val.to_dict(orient='records')\n",
    "dict_train[1]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:30.816364600Z",
     "start_time": "2023-12-13T02:21:30.494372Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "outputs": [],
   "source": [
    "from sklearn.feature_extraction import DictVectorizer\n",
    "dv = DictVectorizer(sparse=False)\n",
    "X_train = dv.fit_transform(dict_train)\n",
    "X_val = dv.transform(dict_val)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:30.962377900Z",
     "start_time": "2023-12-13T02:21:30.576368200Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 6.2 决策树"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "outputs": [
    {
     "data": {
      "text/plain": "DecisionTreeClassifier()"
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.tree import DecisionTreeClassifier\n",
    "dt = DecisionTreeClassifier()\n",
    "dt.fit(X_train,y_train)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:32.730421Z",
     "start_time": "2023-12-13T02:21:30.877401600Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "data": {
      "text/plain": "1.0"
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics import roc_auc_score\n",
    "y_pred = dt.predict_proba(X_train)[:,1]\n",
    "roc_auc_score(y_train,y_pred)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:32.804136800Z",
     "start_time": "2023-12-13T02:21:32.733425600Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "outputs": [
    {
     "data": {
      "text/plain": "0.6584637087985274"
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred = dt.predict_proba(X_val)[:,1]\n",
    "roc_auc_score(y_val,y_pred)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:32.806126400Z",
     "start_time": "2023-12-13T02:21:32.768135200Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 将树的深度修改为2"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "outputs": [
    {
     "data": {
      "text/plain": "DecisionTreeClassifier(max_depth=2)"
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt = DecisionTreeClassifier(max_depth=2)\n",
    "dt.fit(X_train,y_train)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:32.806126400Z",
     "start_time": "2023-12-13T02:21:32.781133500Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "outputs": [
    {
     "data": {
      "text/plain": "0.7054989859726213"
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred = dt.predict_proba(X_train)[:,1]\n",
    "roc_auc_score(y_train,y_pred)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:32.836127Z",
     "start_time": "2023-12-13T02:21:32.798129800Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "outputs": [
    {
     "data": {
      "text/plain": "0.6685264343319367"
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred = dt.predict_proba(X_val)[:,1]\n",
    "roc_auc_score(y_val,y_pred)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:32.837130Z",
     "start_time": "2023-12-13T02:21:32.812129600Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "|--- records=yes <= 0.50\n",
      "|   |--- job=parttime <= 0.50\n",
      "|   |   |--- class: False\n",
      "|   |--- job=parttime >  0.50\n",
      "|   |   |--- class: True\n",
      "|--- records=yes >  0.50\n",
      "|   |--- seniority <= 6.50\n",
      "|   |   |--- class: True\n",
      "|   |--- seniority >  6.50\n",
      "|   |   |--- class: False\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from sklearn.tree import export_text\n",
    "tree_txt = export_text(dt,feature_names=dv.feature_names_)\n",
    "print(tree_txt)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:32.968139500Z",
     "start_time": "2023-12-13T02:21:32.824126900Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 6.2.3 决策树的参数调优"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   1->0.606\n",
      "   2->0.669\n",
      "   3->0.739\n",
      "   4->0.761\n",
      "   5->0.767\n",
      "   6->0.747\n",
      "  10->0.691\n",
      "  15->0.679\n",
      "  20->0.662\n"
     ]
    }
   ],
   "source": [
    "for depth in [1,2,3,4,5,6,10,15,20]:\n",
    "    dt = DecisionTreeClassifier(max_depth=depth)\n",
    "    dt.fit(X_train,y_train)\n",
    "    y_pred = dt.predict_proba(X_val)[:,1]\n",
    "    auc = roc_auc_score(y_val,y_pred)\n",
    "    print(\"%4s->%.3f\"%(depth,auc))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:33.003127400Z",
     "start_time": "2023-12-13T02:21:32.842125700Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "depth:4\n",
      "1->0.761\n",
      "5->0.761\n",
      "10->0.761\n",
      "15->0.764\n",
      "20->0.761\n",
      "50->0.753\n",
      "100->0.756\n",
      "200->0.747\n",
      "depth:5\n",
      "1->0.767\n",
      "5->0.768\n",
      "10->0.762\n",
      "15->0.772\n",
      "20->0.774\n",
      "50->0.768\n",
      "100->0.763\n",
      "200->0.759\n",
      "depth:6\n",
      "1->0.749\n",
      "5->0.762\n",
      "10->0.778\n",
      "15->0.785\n",
      "20->0.774\n",
      "50->0.772\n",
      "100->0.776\n",
      "200->0.768\n"
     ]
    }
   ],
   "source": [
    "for m in [4,5,6]:\n",
    "    print('depth:%s'%m)\n",
    "    for s in [1,5,10,15,20,50,100,200]:\n",
    "        dt = DecisionTreeClassifier(max_depth=m,min_samples_leaf=s)\n",
    "        dt.fit(X_train,y_train)\n",
    "        y_pred = dt.predict_proba(X_val)[:,1]\n",
    "        auc = roc_auc_score(y_val,y_pred)\n",
    "        print('%s->%.3f'%(s,auc))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:33.252124700Z",
     "start_time": "2023-12-13T02:21:32.962129Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 使用最好的参数组合训练最终的模型"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "outputs": [
    {
     "data": {
      "text/plain": "DecisionTreeClassifier(max_depth=6, min_samples_leaf=15)"
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt = DecisionTreeClassifier(max_depth=6,min_samples_leaf=15)\n",
    "dt.fit(X_train,y_train)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:33.253129800Z",
     "start_time": "2023-12-13T02:21:33.217132200Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 随机森林"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "outputs": [
    {
     "data": {
      "text/plain": "RandomForestClassifier(n_estimators=10, random_state=3)"
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.ensemble import RandomForestClassifier\n",
    "rf = RandomForestClassifier(n_estimators=10,random_state=3)\n",
    "rf.fit(X_train,y_train)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:33.451130400Z",
     "start_time": "2023-12-13T02:21:33.239124900Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "outputs": [
    {
     "data": {
      "text/plain": "0.7811145285897654"
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred = rf.predict_proba(X_val)[:,1]\n",
    "roc_auc_score(y_val,y_pred)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:33.533160Z",
     "start_time": "2023-12-13T02:21:33.453128200Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 迭代不同数量的树"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10->0.781\n",
      "20->0.801\n",
      "30->0.813\n",
      "40->0.815\n",
      "50->0.816\n",
      "60->0.817\n",
      "70->0.818\n",
      "80->0.818\n",
      "90->0.820\n",
      "100->0.819\n",
      "110->0.819\n",
      "120->0.821\n",
      "130->0.822\n",
      "140->0.822\n",
      "150->0.820\n",
      "160->0.820\n",
      "170->0.819\n",
      "180->0.820\n",
      "190->0.820\n",
      "200->0.820\n"
     ]
    }
   ],
   "source": [
    "aucs = [] # 创建一个带有AUC结果的列表\n",
    "for i in range(10,201,10):\n",
    "    rf = RandomForestClassifier(n_estimators=i,random_state=3) # 在每次迭代中,逐步训练更多的树\n",
    "    rf.fit(X_train,y_train)\n",
    "\n",
    "    y_pred = rf.predict_proba(X_val)[:,1]\n",
    "    auc = roc_auc_score(y_val,y_pred)\n",
    "    print('{}->{:.3f}'.format(i,auc))\n",
    "    aucs.append(auc) # 将该分数添加到列表中"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:42.680128800Z",
     "start_time": "2023-12-13T02:21:33.471143600Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3deXRcZ5nn8e+j1dpl7d7lRXLspLGTFk7iJJBJIFtDAt00nTRM03T3ZHIGTsP0cghwpk+6GaahaTjDHDLx0NOZsA3pZpsOdJoEEhLADomdxcSbNlveXdpsqbSrVM/8USVFViS7bC1VuvX7nKNTVbfulZ66VedXV+997/uauyMiIsGVkewCRERkfinoRUQCTkEvIhJwCnoRkYBT0IuIBFxWsguYTkVFhdfW1ia7DBGRRePll1/udPfK6Z5LyaCvra1lz549yS5DRGTRMLOjMz2nphsRkYBT0IuIBJyCXkQk4BT0IiIBp6AXEQk4Bb2ISMAp6EVEAi4l+9GLyKVp7x3iucYOOvqG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FyOUUZRNAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(range(10,201,10),aucs)\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:21:43.059267300Z",
     "start_time": "2023-12-13T02:21:42.681137Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 测试max_depth的值"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "depth:5\n",
      "树的数量:10->auc:0.788\n",
      "树的数量:20->auc:0.798\n",
      "树的数量:30->auc:0.800\n",
      "树的数量:40->auc:0.800\n",
      "树的数量:50->auc:0.800\n",
      "树的数量:60->auc:0.801\n",
      "树的数量:70->auc:0.802\n",
      "树的数量:80->auc:0.803\n",
      "树的数量:90->auc:0.804\n",
      "树的数量:100->auc:0.804\n",
      "树的数量:110->auc:0.807\n",
      "树的数量:120->auc:0.806\n",
      "树的数量:130->auc:0.808\n",
      "树的数量:140->auc:0.807\n",
      "树的数量:150->auc:0.807\n",
      "树的数量:160->auc:0.807\n",
      "树的数量:170->auc:0.807\n",
      "树的数量:180->auc:0.807\n",
      "树的数量:190->auc:0.807\n",
      "树的数量:200->auc:0.807\n",
      "\n",
      "depth:10\n",
      "树的数量:10->auc:0.791\n",
      "树的数量:20->auc:0.808\n",
      "树的数量:30->auc:0.812\n",
      "树的数量:40->auc:0.818\n",
      "树的数量:50->auc:0.817\n",
      "树的数量:60->auc:0.819\n",
      "树的数量:70->auc:0.820\n",
      "树的数量:80->auc:0.820\n",
      "树的数量:90->auc:0.820\n",
      "树的数量:100->auc:0.821\n",
      "树的数量:110->auc:0.823\n",
      "树的数量:120->auc:0.823\n",
      "树的数量:130->auc:0.825\n",
      "树的数量:140->auc:0.824\n",
      "树的数量:150->auc:0.824\n",
      "树的数量:160->auc:0.825\n",
      "树的数量:170->auc:0.825\n",
      "树的数量:180->auc:0.825\n",
      "树的数量:190->auc:0.825\n",
      "树的数量:200->auc:0.825\n",
      "\n",
      "depth:20\n",
      "树的数量:10->auc:0.776\n",
      "树的数量:20->auc:0.803\n",
      "树的数量:30->auc:0.813\n",
      "树的数量:40->auc:0.817\n",
      "树的数量:50->auc:0.815\n",
      "树的数量:60->auc:0.813\n",
      "树的数量:70->auc:0.814\n",
      "树的数量:80->auc:0.815\n",
      "树的数量:90->auc:0.814\n",
      "树的数量:100->auc:0.815\n",
      "树的数量:110->auc:0.817\n",
      "树的数量:120->auc:0.816\n",
      "树的数量:130->auc:0.818\n",
      "树的数量:140->auc:0.818\n",
      "树的数量:150->auc:0.818\n",
      "树的数量:160->auc:0.818\n",
      "树的数量:170->auc:0.817\n",
      "树的数量:180->auc:0.817\n",
      "树的数量:190->auc:0.817\n",
      "树的数量:200->auc:0.818\n",
      "\n"
     ]
    }
   ],
   "source": [
    "all_aucs = {} # 创建一个带有AUC结果的字典\n",
    "for depth in [5,10,20]: # 遍历不同深度的值\n",
    "    print('depth:{}'.format(depth))\n",
    "    aucs = [] # 为当前深度创建一个带有auc结果的列表\n",
    "    for i in range(10,201,10):\n",
    "        rf = RandomForestClassifier(n_estimators=i,max_depth=depth,random_state=1)\n",
    "        rf.fit(X_train,y_train)\n",
    "        y_pred = rf.predict_proba(X_val)[:,1]\n",
    "        auc = roc_auc_score(y_val,y_pred)\n",
    "        aucs.append(auc)\n",
    "        print('树的数量:{}->auc:{:.3f}'.format(i,auc))\n",
    "    all_aucs[depth] = aucs # 在字典中保存当前深度层次的AUC\n",
    "    print()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:03.448266400Z",
     "start_time": "2023-12-13T02:21:43.046266400Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes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i3zVKUY+GfqbftvGVCptT7Zo8wj+69Ppoz4758E/VkopUKBV4Dvaq2bgP8B0oFMoBzjT0FPWaq1ng+sAe5WSi33YF0GpJSyANcDL7uKvGn/nY0aoMxj45GVUj8F7MDzrqJyIFlrfSHwPeAFpVS4B6o22M/Uq/YfcAu9Gxwe2X8DZMqgmw5Qdl77T4L+DJRS/hg/kOe11psAtNaVWmuH1toJ/IUR/lP0TLTWZa5lFbDZVZdKpdREANeyylP1c1kD7NNaV4J37b8eBttnpUBSj+0SgbJRrhsASqmvANcCt2pXB67rT/pa1/29GH2400a7bmf4mXrT/vMDbgT+2VXmif03UKYwCr9/EvSDcPXnPQMc1Vr/vkf5xB6brQUO9X3uaFBKhSilwrruYxywOwRsBb7i2uwrwBZP1K+HXq0ob9l/fQy2z7YC65VSAUqpVCAD2D3alVNKrQbuB67XWrf1KI9TSpld99Nc9cv3QP0G+5l6xf5zWQkc01qXdhWM9v4bLFMYjd+/0TriPNZuwCUYfyYdAHJct6uBvwMHXeVbgYkeql8axhH5/cBh4Keu8hjgPeCkaxntwX0YDNQCET3KPLr/ML50ygEbRovp62faZ8BPMVp6x4E1HqpfLkZfbdfv4VOubW9y/ez3A/uA6zxUv0F/pt6w/1zlzwJ39dl2VPffGTJlxH//ZAoEIYTwcdJ1I4QQPk6CXgghfJwEvRBC+DgJeiGE8HES9EII4eMk6IUQwsdJ0AshhI/7/3JhklzoKZ98AAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "num_trees = list(range(10,201,10))\n",
    "plt.plot(num_trees,all_aucs[5],label='depth=5')\n",
    "plt.plot(num_trees,all_aucs[10],label='depth=10')\n",
    "plt.plot(num_trees,all_aucs[20],label='depth=20')\n",
    "plt.legend()\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:03.672268100Z",
     "start_time": "2023-12-13T02:22:03.455296300Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 确定最小划分节点的参数值"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "min_samples_leaf:3\n",
      "树的数量:10, auc:0.8107577922549707\n",
      "树的数量:30, auc:0.822530938945533\n",
      "树的数量:50, auc:0.8229365963527162\n",
      "树的数量:70, auc:0.8215379864861592\n",
      "树的数量:90, auc:0.8232817078782301\n",
      "树的数量:110, auc:0.8234027996415685\n",
      "树的数量:130, auc:0.8244139158654429\n",
      "树的数量:150, auc:0.8248498462134606\n",
      "树的数量:170, auc:0.8249588288004649\n",
      "树的数量:190, auc:0.8251465210336393\n",
      "\n",
      "min_samples_leaf:5\n",
      "树的数量:10, auc:0.8129465258773099\n",
      "树的数量:30, auc:0.817802305587174\n",
      "树的数量:50, auc:0.821265530018648\n",
      "树的数量:70, auc:0.8221979365963527\n",
      "树的数量:90, auc:0.8224703930638638\n",
      "树的数量:110, auc:0.8245471168051149\n",
      "树的数量:130, auc:0.8252857765614783\n",
      "树的数量:150, auc:0.825031483858468\n",
      "树的数量:170, auc:0.8248680099779613\n",
      "树的数量:190, auc:0.8259517812598386\n",
      "\n",
      "min_samples_leaf:10\n",
      "树的数量:10, auc:0.809664939090843\n",
      "树的数量:30, auc:0.822319028359691\n",
      "树的数量:50, auc:0.8223795742413602\n",
      "树的数量:70, auc:0.8193825530987382\n",
      "树的数量:90, auc:0.820369450969945\n",
      "树的数量:110, auc:0.8198305926230898\n",
      "树的数量:130, auc:0.820514761085951\n",
      "树的数量:150, auc:0.8203391780291106\n",
      "树的数量:170, auc:0.8199032476810927\n",
      "树的数量:190, auc:0.8197579375650867\n",
      "\n"
     ]
    }
   ],
   "source": [
    "all_aucs = {}\n",
    "for m in [3,5,10]:\n",
    "    print('min_samples_leaf:{}'.format(m))\n",
    "    aucs = []\n",
    "    for i in range(10,201,20):\n",
    "        rf = RandomForestClassifier(n_estimators=i,max_depth=10,min_samples_leaf=m,random_state=1)\n",
    "        rf.fit(X_train,y_train)\n",
    "        y_pred = rf.predict_proba(X_val)[:,1]\n",
    "        auc = roc_auc_score(y_val,y_pred)\n",
    "        print('树的数量:{}, auc:{}'.format(i,auc))\n",
    "        aucs.append(auc)\n",
    "    all_aucs[m] = aucs\n",
    "    print()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:13.275276200Z",
     "start_time": "2023-12-13T02:22:03.678271100Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD4CAYAAADlwTGnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOzdeXxU1fn48c8zyWRfyQoJkIR9DWBAqyAIFVCr4tK6/awilWLVahd3a2u1lm/F9qtfrZaqtVasWostCopLBZeKJGyJJKAhCZAQQvZ9meX8/rhDCCGQAbJBnvfrNa+Zuffcc8+wnOfec849R4wxKKWU6n9svV0ApZRSvUMDgFJK9VMaAJRSqp/SAKCUUv2UBgCllOqnfHu7AMcjOjraJCUl9XYxlFLqlLJp06YyY0xM++2nVABISkoiIyOjt4uhlFKnFBHZ3dF2bQJSSql+SgOAUkr1UxoAlFKqn9IAoJRS/ZRXAUBE5ovIThHJFZF7O9gfLiJvi8g2EdkuIgs92weLyMcikuPZfke742735LtdRH7XNT9JKaWUNzodBSQiPsAzwPlAIZAuIquMMdltkt0KZBtjLhaRGGCniKwAnMDPjDGbRSQU2CQiHxhjskXkPOBSYKIxpllEYrv6xymllDo6b+4ApgG5xpg8Y0wL8BpWxd2WA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MhnyPfZzXyGizXo65uAp9zOaTSLHQFESVVrVbXMWf8P8Alwh7tRdcp8YKezvhP4sYuxhHIfcEpV4+I/v1X1X8AXQc3hcjgfeFVV/6uqp4GTwGS34lTVA6ra6Dw9BEQ+X3A3CZPPcFzLJ7Qfq/gr9TyMv/Z5wrEBIAZEJB2YCLSUE1ruHG6/GA+nVgAFDojIhyKyxGkboqq14B/MgNtdiy60R7j+lyrecgrhc3gHcDagXw3x8+HgF8D+gOcZIvKRiPxTRH7gVlABQr3P8ZzPHwAXVbU6oC3echqWDQBdJCI3A28AK1W1AfgTkAnkA7X4Dw/dNlVVJwGzgWUiMs3tgNojIn2BecBupykec9qeUPUbXb/fWkTWAI3Ay05TLTBCVScCvwZeEZFb3YqP8O9zXObTsZDrP6jEW07bZQNAF4hIH/x//F9W1TcBVPWiqjapajPwZ3rwUDUcVT3vPNYBb+GP6aKIpAI4j3XuRdjGbKBMVS9CfObUES6HNcDwgH5pwPkeju06IlIEzAUWqXOy2jmlUu+sf4j/3PoYt2Js532Ou3wCiEhvYAHwWktbvOW0IzYARMk59/cX4BNV/X1Ae2pAtweBY8Hb9iQRuUlEbmlZx39B8BhQAhQ53YqAve5EGNJ1n6riLacBwuWwBHhERPqJSAYwGjjsQnwAiMgDwBPAPFX9JqB9sIgkOeuj8Mf5mTtRtvs+x1U+A8wEjqtqTUtDvOW0Q25fhU7UBfg+/sPQCuCosxQCfwU+dtpLgFSX4xyF/w6KcqASWOO0DwLeAaqdxxS3c+rE1R+oBwYEtLmeU/wDUi3wLf5PpI+1l0NgDf5PfyeA2S7HeRL/OfSWn9OtTt+fOD8T5UAZ8COX4wz7PruVz3CxOu07gKVBfV3LaTSLTQVhjDEeZaeAjDHGo2wAMMYYj7IBwBhjPMoGAGOM8SgbAIwxxqNsADDGGI+yAcAYYzzqf6JKzEWjuSjbAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "num_trees = list(range(10,201,20))\n",
    "plt.plot(num_trees,all_aucs[3],label='min_sample_leaf=3')\n",
    "plt.plot(num_trees,all_aucs[5],label='min_sample_leaf=5')\n",
    "plt.plot(num_trees,all_aucs[10],label='min_sample_leaf=10')\n",
    "plt.legend()\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:13.440279900Z",
     "start_time": "2023-12-13T02:22:13.274270600Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 训练最终的随机森林模型"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "outputs": [
    {
     "data": {
      "text/plain": "RandomForestClassifier(max_depth=10, min_samples_leaf=5, n_estimators=200,\n                       random_state=1)"
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rf = RandomForestClassifier(n_estimators=200,max_depth=10,min_samples_leaf=5,random_state=1)\n",
    "rf.fit(X_train,y_train)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:14.006277500Z",
     "start_time": "2023-12-13T02:22:13.440279900Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 6.4 梯度提升(XGBOOST)"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "outputs": [],
   "source": [
    "import xgboost as xgb"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:14.551453400Z",
     "start_time": "2023-12-13T02:22:14.010275800Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "outputs": [],
   "source": [
    "# 训练XGBoost之前,需要将数据封装到DMatrix(这是一种用于高效查找划分节点的特殊数据结构)\n",
    "dtrain = xgb.DMatrix(X_train,label=y_train,feature_names=dv.feature_names_)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:15.593727400Z",
     "start_time": "2023-12-13T02:22:14.554456500Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\myAnaconda\\lib\\site-packages\\xgboost\\core.py:160: UserWarning: [10:22:15] WARNING: C:\\buildkite-agent\\builds\\buildkite-windows-cpu-autoscaling-group-i-0750514818a16474a-1\\xgboost\\xgboost-ci-windows\\src\\learner.cc:742: \n",
      "Parameters: { \"silent\" } are not used.\n",
      "\n",
      "  warnings.warn(smsg, UserWarning)\n"
     ]
    }
   ],
   "source": [
    "# 设置训练参数\n",
    "xgb_params = {\n",
    "    'eta':0.3,\n",
    "    'max_depth':6,\n",
    "    'min_child_weight':1,\n",
    "    'objective':'binary:logistic',\n",
    "    'nthread':8,\n",
    "    'seed':1,\n",
    "    'silent':1\n",
    "}\n",
    "# 训练模型\n",
    "model = xgb.train(xgb_params,dtrain,num_boost_round=10) # 第三个参数表示要训练的树的数量"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:15.722728Z",
     "start_time": "2023-12-13T02:22:15.598728500Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "outputs": [
    {
     "data": {
      "text/plain": "array([0.07751459, 0.07131889, 0.0675393 , 0.12096145, 0.05379206,\n       0.06382526, 0.06665564, 0.4352498 , 0.41923273, 0.02550563],\n      dtype=float32)"
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dval = xgb.DMatrix(X_val,label=y_val,feature_names=dv.feature_names_)\n",
    "y_pred = model.predict(dval)\n",
    "y_pred[:10]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:15.799728800Z",
     "start_time": "2023-12-13T02:22:15.724730900Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ True  True False  True  True False  True False  True False  True False] [0.6367574  0.4054787  0.04526887 0.16745408 0.7127675  0.03006224\n",
      " 0.5343071  0.04991934 0.27132282 0.05428449 0.37439683 0.04259947]\n"
     ]
    }
   ],
   "source": [
    "print(y_val[11:23],y_pred[11:23])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:26:16.335399700Z",
     "start_time": "2023-12-13T02:26:16.328399200Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "outputs": [
    {
     "data": {
      "text/plain": "0.8065256351262986"
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "roc_auc_score(y_val,y_pred)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:22:15.802737200Z",
     "start_time": "2023-12-13T02:22:15.756731800Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 6.4.2.模型性能监控"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0]\ttrain-auc:0.86730\tval-auc:0.77938\n",
      "[10]\ttrain-auc:0.95447\tval-auc:0.80851\n",
      "[20]\ttrain-auc:0.97464\tval-auc:0.81729\n",
      "[30]\ttrain-auc:0.98579\tval-auc:0.81543\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\myAnaconda\\lib\\site-packages\\xgboost\\core.py:160: UserWarning: [10:51:12] WARNING: C:\\buildkite-agent\\builds\\buildkite-windows-cpu-autoscaling-group-i-0750514818a16474a-1\\xgboost\\xgboost-ci-windows\\src\\learner.cc:742: \n",
      "Parameters: { \"silent\" } are not used.\n",
      "\n",
      "  warnings.warn(smsg, UserWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[40]\ttrain-auc:0.99421\tval-auc:0.80922\n",
      "[50]\ttrain-auc:0.99653\tval-auc:0.80918\n",
      "[60]\ttrain-auc:0.99817\tval-auc:0.81172\n",
      "[70]\ttrain-auc:0.99934\tval-auc:0.80870\n",
      "[80]\ttrain-auc:0.99979\tval-auc:0.80549\n",
      "[90]\ttrain-auc:0.99993\tval-auc:0.80409\n",
      "[99]\ttrain-auc:0.99999\tval-auc:0.80560\n"
     ]
    }
   ],
   "source": [
    "watchlist = [(dtrain,'train'),(dval,'val')]\n",
    "xgb_params = {\n",
    "    'eta':0.3,\n",
    "    'max_depth':6,\n",
    "    'min_child_weight':1,\n",
    "    'objective':'binary:logistic',\n",
    "    'eval_metric':'auc',\n",
    "    'nthread':8,\n",
    "    'seed':1,\n",
    "    'silent':1\n",
    "}\n",
    "# evals:监视列表\n",
    "# verbose_eval:多久输出一次指标,设置为10表示每10步后看到一个结果\n",
    "model = xgb.train(xgb_params,dtrain,num_boost_round=100,evals=watchlist,verbose_eval=10)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:51:13.314015Z",
     "start_time": "2023-12-13T02:51:12.649022500Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## XGBoost的参数调优"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "outputs": [],
   "source": [
    "xgb_params = {\n",
    "    'eta':0.1,# 学习率\n",
    "    'max_depth':6,# 每棵树的最大深度\n",
    "    'min_child_weight':1,# 每组最小观察数，等价于最小划分节点\n",
    "    'objective':'binary:logistic',# 想要解决的分类类型\n",
    "    'eval_metric':'auc',\n",
    "    'nthread':8,# 用于训练的线程数\n",
    "    'seed':1,# 随机数发生器的种子\n",
    "    'silent':1, # 是否开启静默模式,设置为1时,表示只输出警告\n",
    "}"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:52:06.688899200Z",
     "start_time": "2023-12-13T02:52:06.669866400Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0]\ttrain-auc:0.86730\tval-auc:0.77938\n",
      "[10]\ttrain-auc:0.91874\tval-auc:0.80510\n",
      "[20]\ttrain-auc:0.93873\tval-auc:0.81804\n",
      "[30]\ttrain-auc:0.95338\tval-auc:0.82063\n",
      "[40]\ttrain-auc:0.96325\tval-auc:0.82644\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\myAnaconda\\lib\\site-packages\\xgboost\\core.py:160: UserWarning: [10:52:09] WARNING: C:\\buildkite-agent\\builds\\buildkite-windows-cpu-autoscaling-group-i-0750514818a16474a-1\\xgboost\\xgboost-ci-windows\\src\\learner.cc:742: \n",
      "Parameters: { \"silent\" } are not used.\n",
      "\n",
      "  warnings.warn(smsg, UserWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[50]\ttrain-auc:0.97195\tval-auc:0.82549\n",
      "[60]\ttrain-auc:0.97708\tval-auc:0.82781\n",
      "[70]\ttrain-auc:0.98214\tval-auc:0.82681\n",
      "[80]\ttrain-auc:0.98517\tval-auc:0.82560\n",
      "[90]\ttrain-auc:0.98840\tval-auc:0.82443\n",
      "[99]\ttrain-auc:0.99053\tval-auc:0.82420\n"
     ]
    }
   ],
   "source": [
    "model = xgb.train(xgb_params,dtrain,num_boost_round=100,verbose_eval=10,evals=watchlist)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:52:10.817007600Z",
     "start_time": "2023-12-13T02:52:09.717005900Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "#### 2.调优其他参数"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0]\ttrain-auc:0.77610\tval-auc:0.73891\n",
      "[10]\ttrain-auc:0.84675\tval-auc:0.78896\n",
      "[20]\ttrain-auc:0.86931\tval-auc:0.80928\n",
      "[30]\ttrain-auc:0.88080\tval-auc:0.81808\n",
      "[40]\ttrain-auc:0.89038\tval-auc:0.82347\n",
      "[50]\ttrain-auc:0.89756\tval-auc:0.82583\n",
      "[60]\ttrain-auc:0.90319\tval-auc:0.82847\n",
      "[70]\ttrain-auc:0.90768\tval-auc:0.83005\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\myAnaconda\\lib\\site-packages\\xgboost\\core.py:160: UserWarning: [10:58:19] WARNING: C:\\buildkite-agent\\builds\\buildkite-windows-cpu-autoscaling-group-i-0750514818a16474a-1\\xgboost\\xgboost-ci-windows\\src\\learner.cc:742: \n",
      "Parameters: { \"silent\" } are not used.\n",
      "\n",
      "  warnings.warn(smsg, UserWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[80]\ttrain-auc:0.91221\tval-auc:0.83117\n",
      "[90]\ttrain-auc:0.91638\tval-auc:0.83029\n",
      "[100]\ttrain-auc:0.91913\tval-auc:0.83113\n",
      "[110]\ttrain-auc:0.92297\tval-auc:0.83170\n",
      "[120]\ttrain-auc:0.92544\tval-auc:0.83124\n",
      "[130]\ttrain-auc:0.92789\tval-auc:0.83169\n",
      "[140]\ttrain-auc:0.92996\tval-auc:0.83088\n",
      "[150]\ttrain-auc:0.93200\tval-auc:0.83108\n",
      "[160]\ttrain-auc:0.93416\tval-auc:0.83154\n",
      "[170]\ttrain-auc:0.93638\tval-auc:0.83129\n",
      "[180]\ttrain-auc:0.93842\tval-auc:0.83046\n",
      "[190]\ttrain-auc:0.94005\tval-auc:0.83014\n",
      "[200]\ttrain-auc:0.94181\tval-auc:0.82986\n",
      "[210]\ttrain-auc:0.94374\tval-auc:0.82907\n",
      "[220]\ttrain-auc:0.94529\tval-auc:0.82902\n",
      "[230]\ttrain-auc:0.94725\tval-auc:0.82884\n",
      "[240]\ttrain-auc:0.94840\tval-auc:0.82846\n",
      "[250]\ttrain-auc:0.94951\tval-auc:0.82877\n",
      "[260]\ttrain-auc:0.95073\tval-auc:0.82834\n",
      "[270]\ttrain-auc:0.95199\tval-auc:0.82806\n",
      "[280]\ttrain-auc:0.95356\tval-auc:0.82778\n",
      "[290]\ttrain-auc:0.95489\tval-auc:0.82745\n",
      "[299]\ttrain-auc:0.95621\tval-auc:0.82650\n"
     ]
    }
   ],
   "source": [
    "xgb_params = {\n",
    "    'eta':0.1,# 学习率\n",
    "    'max_depth':3,# 每棵树的最大深度\n",
    "    'min_child_weight':1,# 每组最小观察数，等价于最小划分节点\n",
    "    'objective':'binary:logistic',# 想要解决的分类类型\n",
    "    'eval_metric':'auc',\n",
    "    'nthread':8,# 用于训练的线程数\n",
    "    'seed':1,# 随机数发生器的种子\n",
    "    'silent':1, # 是否开启静默模式,设置为1时,表示只输出警告\n",
    "}\n",
    "# 修改树的深度\n",
    "model = xgb.train(xgb_params,dtrain,num_boost_round=300,verbose_eval=10,evals=watchlist)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:58:20.323086Z",
     "start_time": "2023-12-13T02:58:19.135086800Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0]\ttrain-auc:0.92435\tval-auc:0.76925\n",
      "[10]\ttrain-auc:0.97894\tval-auc:0.79427\n",
      "[20]\ttrain-auc:0.99325\tval-auc:0.80124\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\myAnaconda\\lib\\site-packages\\xgboost\\core.py:160: UserWarning: [10:58:55] WARNING: C:\\buildkite-agent\\builds\\buildkite-windows-cpu-autoscaling-group-i-0750514818a16474a-1\\xgboost\\xgboost-ci-windows\\src\\learner.cc:742: \n",
      "Parameters: { \"silent\" } are not used.\n",
      "\n",
      "  warnings.warn(smsg, UserWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[30]\ttrain-auc:0.99752\tval-auc:0.80508\n",
      "[40]\ttrain-auc:0.99909\tval-auc:0.80593\n",
      "[50]\ttrain-auc:0.99966\tval-auc:0.80953\n",
      "[60]\ttrain-auc:0.99992\tval-auc:0.81151\n",
      "[70]\ttrain-auc:0.99997\tval-auc:0.81308\n",
      "[80]\ttrain-auc:0.99999\tval-auc:0.81296\n",
      "[90]\ttrain-auc:1.00000\tval-auc:0.81382\n",
      "[100]\ttrain-auc:1.00000\tval-auc:0.81405\n",
      "[110]\ttrain-auc:1.00000\tval-auc:0.81345\n",
      "[120]\ttrain-auc:1.00000\tval-auc:0.81405\n",
      "[130]\ttrain-auc:1.00000\tval-auc:0.81458\n",
      "[140]\ttrain-auc:1.00000\tval-auc:0.81403\n",
      "[150]\ttrain-auc:1.00000\tval-auc:0.81328\n",
      "[160]\ttrain-auc:1.00000\tval-auc:0.81249\n",
      "[170]\ttrain-auc:1.00000\tval-auc:0.81240\n",
      "[180]\ttrain-auc:1.00000\tval-auc:0.81219\n",
      "[190]\ttrain-auc:1.00000\tval-auc:0.81224\n",
      "[200]\ttrain-auc:1.00000\tval-auc:0.81214\n",
      "[210]\ttrain-auc:1.00000\tval-auc:0.81196\n",
      "[220]\ttrain-auc:1.00000\tval-auc:0.81199\n",
      "[230]\ttrain-auc:1.00000\tval-auc:0.81186\n",
      "[240]\ttrain-auc:1.00000\tval-auc:0.81098\n",
      "[250]\ttrain-auc:1.00000\tval-auc:0.81107\n",
      "[260]\ttrain-auc:1.00000\tval-auc:0.81086\n",
      "[270]\ttrain-auc:1.00000\tval-auc:0.81075\n",
      "[280]\ttrain-auc:1.00000\tval-auc:0.81052\n",
      "[290]\ttrain-auc:1.00000\tval-auc:0.81061\n",
      "[299]\ttrain-auc:1.00000\tval-auc:0.81036\n"
     ]
    }
   ],
   "source": [
    "xgb_params = {\n",
    "    'eta':0.1,# 学习率\n",
    "    'max_depth':10,# 每棵树的最大深度\n",
    "    'min_child_weight':1,# 每组最小观察数，等价于最小划分节点\n",
    "    'objective':'binary:logistic',# 想要解决的分类类型\n",
    "    'eval_metric':'auc',\n",
    "    'nthread':8,# 用于训练的线程数\n",
    "    'seed':1,# 随机数发生器的种子\n",
    "    'silent':1, # 是否开启静默模式,设置为1时,表示只输出警告\n",
    "}\n",
    "# 修改树的深度\n",
    "model = xgb.train(xgb_params,dtrain,num_boost_round=300,verbose_eval=10,evals=watchlist)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:58:56.555562100Z",
     "start_time": "2023-12-13T02:58:55.109557600Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# 最终模型"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0]\ttrain-auc:0.92435\tval-auc:0.76925\n",
      "[10]\ttrain-auc:0.97894\tval-auc:0.79427\n",
      "[20]\ttrain-auc:0.99325\tval-auc:0.80124\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\myAnaconda\\lib\\site-packages\\xgboost\\core.py:160: UserWarning: [10:59:56] WARNING: C:\\buildkite-agent\\builds\\buildkite-windows-cpu-autoscaling-group-i-0750514818a16474a-1\\xgboost\\xgboost-ci-windows\\src\\learner.cc:742: \n",
      "Parameters: { \"silent\" } are not used.\n",
      "\n",
      "  warnings.warn(smsg, UserWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[30]\ttrain-auc:0.99752\tval-auc:0.80508\n",
      "[40]\ttrain-auc:0.99909\tval-auc:0.80593\n",
      "[50]\ttrain-auc:0.99966\tval-auc:0.80953\n",
      "[60]\ttrain-auc:0.99992\tval-auc:0.81151\n",
      "[70]\ttrain-auc:0.99997\tval-auc:0.81308\n",
      "[80]\ttrain-auc:0.99999\tval-auc:0.81296\n",
      "[90]\ttrain-auc:1.00000\tval-auc:0.81382\n",
      "[100]\ttrain-auc:1.00000\tval-auc:0.81405\n",
      "[110]\ttrain-auc:1.00000\tval-auc:0.81345\n",
      "[120]\ttrain-auc:1.00000\tval-auc:0.81405\n",
      "[130]\ttrain-auc:1.00000\tval-auc:0.81458\n",
      "[140]\ttrain-auc:1.00000\tval-auc:0.81403\n",
      "[150]\ttrain-auc:1.00000\tval-auc:0.81328\n",
      "[160]\ttrain-auc:1.00000\tval-auc:0.81249\n",
      "[170]\ttrain-auc:1.00000\tval-auc:0.81240\n",
      "[180]\ttrain-auc:1.00000\tval-auc:0.81219\n",
      "[190]\ttrain-auc:1.00000\tval-auc:0.81224\n",
      "[200]\ttrain-auc:1.00000\tval-auc:0.81214\n",
      "[210]\ttrain-auc:1.00000\tval-auc:0.81196\n",
      "[220]\ttrain-auc:1.00000\tval-auc:0.81199\n",
      "[230]\ttrain-auc:1.00000\tval-auc:0.81186\n",
      "[240]\ttrain-auc:1.00000\tval-auc:0.81098\n",
      "[250]\ttrain-auc:1.00000\tval-auc:0.81107\n",
      "[260]\ttrain-auc:1.00000\tval-auc:0.81086\n",
      "[270]\ttrain-auc:1.00000\tval-auc:0.81075\n",
      "[280]\ttrain-auc:1.00000\tval-auc:0.81052\n",
      "[290]\ttrain-auc:1.00000\tval-auc:0.81061\n",
      "[299]\ttrain-auc:1.00000\tval-auc:0.81036\n",
      "[0]\ttrain-auc:0.77610\tval-auc:0.73891\n",
      "[10]\ttrain-auc:0.84675\tval-auc:0.78896\n",
      "[20]\ttrain-auc:0.86931\tval-auc:0.80928\n",
      "[30]\ttrain-auc:0.88080\tval-auc:0.81808\n",
      "[40]\ttrain-auc:0.89038\tval-auc:0.82347\n",
      "[50]\ttrain-auc:0.89756\tval-auc:0.82583\n",
      "[60]\ttrain-auc:0.90319\tval-auc:0.82847\n",
      "[70]\ttrain-auc:0.90768\tval-auc:0.83005\n",
      "[80]\ttrain-auc:0.91221\tval-auc:0.83117\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\myAnaconda\\lib\\site-packages\\xgboost\\core.py:160: UserWarning: [10:59:57] WARNING: C:\\buildkite-agent\\builds\\buildkite-windows-cpu-autoscaling-group-i-0750514818a16474a-1\\xgboost\\xgboost-ci-windows\\src\\learner.cc:742: \n",
      "Parameters: { \"silent\" } are not used.\n",
      "\n",
      "  warnings.warn(smsg, UserWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[90]\ttrain-auc:0.91638\tval-auc:0.83029\n",
      "[100]\ttrain-auc:0.91913\tval-auc:0.83113\n",
      "[110]\ttrain-auc:0.92297\tval-auc:0.83170\n",
      "[120]\ttrain-auc:0.92544\tval-auc:0.83124\n",
      "[130]\ttrain-auc:0.92789\tval-auc:0.83169\n",
      "[140]\ttrain-auc:0.92996\tval-auc:0.83088\n",
      "[150]\ttrain-auc:0.93200\tval-auc:0.83108\n",
      "[160]\ttrain-auc:0.93416\tval-auc:0.83154\n",
      "[170]\ttrain-auc:0.93638\tval-auc:0.83129\n",
      "[180]\ttrain-auc:0.93842\tval-auc:0.83046\n",
      "[190]\ttrain-auc:0.94005\tval-auc:0.83014\n",
      "[200]\ttrain-auc:0.94181\tval-auc:0.82986\n",
      "[210]\ttrain-auc:0.94374\tval-auc:0.82907\n",
      "[220]\ttrain-auc:0.94529\tval-auc:0.82902\n",
      "[230]\ttrain-auc:0.94725\tval-auc:0.82884\n",
      "[240]\ttrain-auc:0.94840\tval-auc:0.82846\n",
      "[250]\ttrain-auc:0.94951\tval-auc:0.82877\n",
      "[260]\ttrain-auc:0.95073\tval-auc:0.82834\n",
      "[270]\ttrain-auc:0.95199\tval-auc:0.82806\n",
      "[280]\ttrain-auc:0.95356\tval-auc:0.82778\n",
      "[290]\ttrain-auc:0.95489\tval-auc:0.82745\n",
      "[299]\ttrain-auc:0.95621\tval-auc:0.82650\n"
     ]
    }
   ],
   "source": [
    "xgb_params = {\n",
    "    'eta': 0.1,  # 学习率\n",
    "    'max_depth': 3,  # 每棵树的最大深度\n",
    "    'min_child_weight': 1,  # 每组最小观察数，等价于最小划分节点\n",
    "    'objective': 'binary:logistic',  # 想要解决的分类类型\n",
    "    'eval_metric': 'auc',\n",
    "    'nthread': 8,  # 用于训练的线程数\n",
    "    'seed': 1,  # 随机数发生器的种子\n",
    "    'silent': 1,  # 是否开启静默模式,设置为1时,表示只输出警告\n",
    "}\n",
    "# 修改树的深度\n",
    "model = xgb.train(xgb_params, dtrain, num_boost_round=300, verbose_eval=10, evals=watchlist)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T02:59:58.147471500Z",
     "start_time": "2023-12-13T02:59:56.191472300Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 测试最终模型"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "outputs": [],
   "source": [
    "y_train = (df_train_full.status=='default').values\n",
    "y_test = (df_test.status == 'default').values\n",
    "del df_train_full['status']\n",
    "del df_test['status']"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T03:04:20.892580700Z",
     "start_time": "2023-12-13T03:04:19.550575800Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "outputs": [],
   "source": [
    "## 将dataframe转化为字典\n",
    "dict_train = df_train_full.fillna(0).to_dict(orient='records')\n",
    "dict_test = df_test.fillna(0).to_dict(orient='records')\n",
    "dv = DictVectorizer(sparse=False) # sparse表示创建一个numpy数组\n",
    "X_train = dv.fit_transform(dict_train)\n",
    "X_test = dv.transform(dict_test)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T03:08:51.161207300Z",
     "start_time": "2023-12-13T03:08:49.244203600Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0]\ttrain-auc:0.76536\ttest-auc:0.72194\n",
      "[10]\ttrain-auc:0.84007\ttest-auc:0.79462\n",
      "[20]\ttrain-auc:0.85628\ttest-auc:0.80817\n",
      "[30]\ttrain-auc:0.86759\ttest-auc:0.81990\n",
      "[40]\ttrain-auc:0.87748\ttest-auc:0.82615\n",
      "[50]\ttrain-auc:0.88421\ttest-auc:0.83038\n",
      "[60]\ttrain-auc:0.88882\ttest-auc:0.83260\n",
      "[70]\ttrain-auc:0.89382\ttest-auc:0.83452\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\myAnaconda\\lib\\site-packages\\xgboost\\core.py:160: UserWarning: [11:12:31] WARNING: C:\\buildkite-agent\\builds\\buildkite-windows-cpu-autoscaling-group-i-0750514818a16474a-1\\xgboost\\xgboost-ci-windows\\src\\learner.cc:742: \n",
      "Parameters: { \"silent\" } are not used.\n",
      "\n",
      "  warnings.warn(smsg, UserWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[80]\ttrain-auc:0.89724\ttest-auc:0.83615\n",
      "[90]\ttrain-auc:0.90048\ttest-auc:0.83624\n",
      "[100]\ttrain-auc:0.90402\ttest-auc:0.83569\n",
      "[110]\ttrain-auc:0.90651\ttest-auc:0.83572\n",
      "[120]\ttrain-auc:0.90930\ttest-auc:0.83553\n",
      "[130]\ttrain-auc:0.91262\ttest-auc:0.83450\n",
      "[140]\ttrain-auc:0.91455\ttest-auc:0.83417\n",
      "[150]\ttrain-auc:0.91682\ttest-auc:0.83327\n",
      "[160]\ttrain-auc:0.91874\ttest-auc:0.83398\n",
      "[170]\ttrain-auc:0.92074\ttest-auc:0.83351\n",
      "[180]\ttrain-auc:0.92272\ttest-auc:0.83303\n",
      "[190]\ttrain-auc:0.92451\ttest-auc:0.83158\n",
      "[200]\ttrain-auc:0.92635\ttest-auc:0.83165\n",
      "[210]\ttrain-auc:0.92812\ttest-auc:0.83139\n",
      "[220]\ttrain-auc:0.92919\ttest-auc:0.83138\n",
      "[230]\ttrain-auc:0.93123\ttest-auc:0.83098\n",
      "[240]\ttrain-auc:0.93257\ttest-auc:0.83088\n",
      "[250]\ttrain-auc:0.93395\ttest-auc:0.83055\n",
      "[260]\ttrain-auc:0.93545\ttest-auc:0.83003\n",
      "[270]\ttrain-auc:0.93673\ttest-auc:0.83005\n",
      "[280]\ttrain-auc:0.93830\ttest-auc:0.82961\n",
      "[290]\ttrain-auc:0.93940\ttest-auc:0.82867\n",
      "[299]\ttrain-auc:0.94033\ttest-auc:0.82813\n"
     ]
    }
   ],
   "source": [
    "dtrain = xgb.DMatrix(X_train,label=y_train,feature_names=dv.feature_names_)\n",
    "dtest = xgb.DMatrix(X_test,label=y_test,feature_names=dv.feature_names_)\n",
    "watchlist = [(dtrain,'train'),(dtest,'test')]\n",
    "xgb_params = {\n",
    "    'eta': 0.1,  # 学习率\n",
    "    'max_depth': 3,  # 每棵树的最大深度\n",
    "    'min_child_weight': 1,  # 每组最小观察数，等价于最小划分节点\n",
    "    'objective': 'binary:logistic',  # 想要解决的分类类型\n",
    "    'eval_metric': 'auc',\n",
    "    'nthread': 8,  # 用于训练的线程数\n",
    "    'seed': 1,  # 随机数发生器的种子\n",
    "    'silent': 1,  # 是否开启静默模式,设置为1时,表示只输出警告\n",
    "}\n",
    "# 修改树的深度\n",
    "model = xgb.train(xgb_params, dtrain, num_boost_round=300, verbose_eval=10, evals=watchlist)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T03:12:32.153159Z",
     "start_time": "2023-12-13T03:12:31.050185Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "outputs": [
    {
     "data": {
      "text/plain": "(array([[0.1359505 ],\n        [0.15793173],\n        [0.3499759 ],\n        [0.2372302 ],\n        [0.22493234],\n        [0.5543368 ],\n        [0.10395411],\n        [0.67576915],\n        [0.09295266],\n        [0.78170836],\n        [0.01862004],\n        [0.02688213],\n        [0.88768846],\n        [0.6326677 ],\n        [0.09629443]], dtype=float32),\n array([False, False, False,  True,  True, False,  True,  True, False,\n         True, False, False,  True,  True, False]))"
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred=model.predict(dtest,strict_shape=True)\n",
    "y_pred[10:25],y_test[10:25]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T04:43:05.666952100Z",
     "start_time": "2023-12-13T04:43:05.629950500Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "outputs": [
    {
     "data": {
      "text/plain": "0.8281303455354089"
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "roc_auc_score(y_test,y_pred)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T04:43:52.132017600Z",
     "start_time": "2023-12-13T04:43:50.423987300Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "outputs": [
    {
     "data": {
      "text/plain": "array([[539,  93],\n       [109, 150]], dtype=int64)"
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics import confusion_matrix\n",
    "y_pred_class = []\n",
    "for i in y_pred:\n",
    "    if i>=0.4:\n",
    "        y_pred_class.append(1)\n",
    "    else:\n",
    "        y_pred_class.append(0)\n",
    "confusion_matrix(y_test,y_pred_class)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T05:17:24.699099900Z",
     "start_time": "2023-12-13T05:17:24.649061Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "outputs": [
    {
     "data": {
      "text/plain": "0.7789001122334456"
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(y_pred_class==y_test).mean()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T04:56:01.040182600Z",
     "start_time": "2023-12-13T04:56:01.001984400Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "outputs": [
    {
     "data": {
      "text/plain": "array([0.53333333, 0.06542056, 0.01703163, 0.11904762, 0.20333333,\n       0.30215827, 0.01703163, 0.01703163, 0.3125    , 0.20333333])"
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred=dt.predict_proba(X_test)[:,1]\n",
    "y_pred[:10]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T05:07:54.217476200Z",
     "start_time": "2023-12-13T05:07:54.005475100Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "outputs": [
    {
     "data": {
      "text/plain": "0.777173647426812"
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "roc_auc_score(y_test,y_pred)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T05:09:15.426015600Z",
     "start_time": "2023-12-13T05:09:15.346015200Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "outputs": [
    {
     "data": {
      "text/plain": "0.7497194163860831"
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt.score(X_test,y_test)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T05:09:51.102444100Z",
     "start_time": "2023-12-13T05:09:51.017407500Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 随机森林"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "outputs": [
    {
     "data": {
      "text/plain": "0.8241777039245393"
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred=rf.predict_proba(X_test)[:,1]\n",
    "roc_auc_score(y_test,y_pred)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T05:12:08.973930100Z",
     "start_time": "2023-12-13T05:12:07.567237Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "outputs": [
    {
     "data": {
      "text/plain": "0.7744107744107744"
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rf.score(X_test,y_test)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T05:13:11.640358800Z",
     "start_time": "2023-12-13T05:13:11.544358200Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "outputs": [
    {
     "data": {
      "text/plain": "array([[574,  58],\n       [143, 116]], dtype=int64)"
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "confusion_matrix(y_test,rf.predict(X_test))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-12-13T05:15:39.174359400Z",
     "start_time": "2023-12-13T05:15:39.118361300Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
